/**
 * 新增修改完成调用 modalFormOk方法 编辑弹框组件ref定义为modalForm
 * 高级查询按钮调用 superQuery方法  高级查询组件ref定义为superQueryModal
 * data中url定义 list为查询列表  delete为删除单条记录  deleteBatch为批量删除
 */
import { filterObj } from '@/utils/util'
import {
  httpAction,
  deleteAction,
  getAction,
  downFile,
  getFileAccessHttpUrl,
  getJSON,
  postAction,
  putAction
} from '@/api/manage'
import { ajaxGetDictItems, getDictItemsFromCache, getProductCategory } from '@/api/api'
import Vue from 'vue'
import { ACCESS_TOKEN } from '@/store/mutation-types'
import moment from 'moment'
import { initDictOptions } from '@comp/dict/CnDictSelectUtil'

let self
export const PageListMixin = {
  data() {
    return {
      // 新主数据界面，左边树查询
      searchOn: {},
      // 树数据
      treeData: [],
      //token header
      tokenHeader: {
        'loginUserToken': Vue.ls.get(ACCESS_TOKEN).loginUserToken,
        'Authorization':`Bearer ${Vue.ls.get(ACCESS_TOKEN).access_token}`
      },
      /* 查询条件-请不要在queryParam中声明非字符串值的属性 */
      queryParam: {},
      /* 数据源 */
      dataSource: [],
      /* 分页参数 */
      ipagination: {
        current: 1,
        pageSize: 10,
        pageSizeOptions: [5, 10, 20, 30, 40, 50],
        showTotal: (total, range) => {
          return range[0] + '-' + range[1] + ' 共' + total + '条'
        },
        showQuickJumper: true,
        showSizeChanger: true,
        total: 0
      },
      /* 排序参数 */
      isorter: {
        column: 'createTime',
        order: 'desc'
      },
      /* 筛选参数 */
      filters: {},
      /* table加载状态 */
      loading: false,
      /* table选中keys*/
      selectedRowKeys: [],
      /* table选中records*/
      selectionRows: [],
      /* 查询折叠 */
      toggleSearchStatus: false,
      /* 高级查询条件生效状态 */
      superQueryFlag: false,
      /* 高级查询条件 */
      superQueryParams: '',
      /** 高级查询拼接方式 */
      superQueryMatchType: 'and',
      /**选中行*/
      selectData: {},
      seachHeight: 43,
      /* vxe-table keys */
      tableKey: 'id',
      tableToolbar: {
        zoom: true,
        custom: true,
        slots: {
          buttons: 'toolbar_buttons'
        }
      },
      checkboxConfig: {
        // showHeader:true,
        trigger: 'row',
        highlight: true,
        checkStrictly:true,

      },
      vexConfig: {
        rowConfig: { isHover: true }

      },

      OrderStatus: {
        '-20': '已取消',
        '-10': '取消确认',
        '60': '待发货',
        '80': '已发货',
        '100': '已完成'
      }
    }
  },
  async created() {
    self = this
    if (!this.disableMixinCreated) {
      // console.log(' -- mixin created -- ')
      await this.initDictConfig()
      this.loadData(1)
      //初始化字典配置 在自己页面定义
    }
  },
  computed: {
    pageHeight() {
      return this.$store.state.app.pageHeight || document.body.clientHeight
    }
  },
  methods: {
    // vxe表格单选
    radioChangeEvent({ row }) {
      this.selectionRows = [row]
      this.selectedRowKeys = [row[this.tableKey]]
    },
    // vxe表格多选
    selectChangeEvent() {
      const $grid = this.$refs.xGrid
      this.selectionRows = $grid.getCheckboxRecords()
      this.selectedRowKeys = this.selectionRows.map(item => item[this.tableKey])
    },
    // vxe表格分页
    handlePageChange({ currentPage, pageSize }) {
      this.ipagination.currentPage = currentPage
      this.ipagination.pageSize = pageSize
      this.loadData()
    },

    generateUUID(withSeparator = true) {
      let d = new Date().getTime()
      if (window.performance && typeof window.performance.now === 'function') {
        d += performance.now()
      }
      const tpl = withSeparator ? 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx' : 'xxxxxxxxxxxx4xxxyxxxxxxxxxxxxxxx'
      return tpl.replace(/[xy]/g, function (c) {
        const r = (d + Math.random() * 16) % 16 | 0
        d = Math.floor(d / 16)
        return (c === 'x' ? r : (r & 0x3 | 0x8)).toString(16)
      })
    },
    onClickRow(record) {
      return {
        on: {
          click: () => {
            const keys = this.selectedRowKeys
            if (keys.indexOf(record.id) == -1) {
              keys.push(record.id)
              this.selectionRows.push(record)
            } else {
              keys.remove(record.id)
              this.selectionRows.remove(record)
            }
            this.selectedRowKeys = keys

          }
        }
      }
    },
    // 业务日志查询
    handleBusiness(businessName, row) {
      if (businessName instanceof Object) {
        if (row) {
          this.$refs.businessLog.show(row.id)
        } else {
          this.$refs.businessLog.show(this.selectionRows[0].id)
        }
        return
      }
      if (typeof (businessName) == 'string') {
        if (row) {
          this.$refs.businessLog.show(row.id, businessName)
        } else {
          this.$refs.businessLog.show(this.selectionRows[0].id, businessName)
        }
      }
    },
    getHeight(seachHeight) {
      this.seachHeight = seachHeight
    },
    search(queryParam, butType) {
      this.selectedRowKeys = []
      this.selectionRows = []
      this.queryParam = queryParam
      this.loadData(1)
    },
    onSingleClickRow(record) {
      return {
        on: {
          click: () => {
            this.selectData = record
            let keys = this.selectedRowKeys
            if (keys.indexOf(record.id) == -1) {
              keys = []
              this.selectionRows = []
              keys.push(record.id)
              this.selectionRows.push(record)
            } else {
              keys.remove(record.id)
              this.selectionRows.remove(record)
              this.selectData = {}
            }
            this.selectedRowKeys = keys
          }
        }
      }
    },
    loadData(arg) {
      if (!this.url || !this.url.list) {
        // this.$message.error("请设置url.list属性!")
        return
      }
      //加载数据 若传入参数1则加载第一页的内容
      if (arg === 1) {
        this.ipagination.current = 1
      }
      var params = this.getQueryParams()//查询条件
      console.log(params)
      this.loading = true
      // if(['/isys','/isystem'].some(path=> new RegExp(`^${path}`).test(this.$route.fullPath))){
      //   getJSON(this.$route.fullPath).then((res) => {
      //     if (res.success) {
      //       this.dataSource = res.result.records;
      //       this.ipagination.total = res.result.total;
      //     }
      //     if(res.code===510){
      //       this.$message.warning(res.message)
      //     }
      //     this.loading = false;
      //   })
      // }else{
      let request = null
      const isNoPagnation = ['getDictByCode'].some(url => new RegExp(`${url}$`).test(this.url.list))
      if (isNoPagnation) {
        request = getAction
      } else {
        request = postAction
      }
      var that = this
      return request(this.url.list, params).then((res) => {
        if (res.success) {
          let {
            records = [],
            total
          } = res.result
          if (res.result instanceof Array) {
            records = res.result
          }
          that.dataSource = isNoPagnation ? res.result : records
          if (!isNoPagnation) that.ipagination.total = total || 0
        } else {
          that.$message.warning(res.message)
        }
      }).finally(() => {
        // debugger
        that.loading = false
      })
      // }
    },

    // 获取字典数据 假方法
    initDictConfig() {

    },
    handleSuperQuery(params, matchType) {
      //高级查询方法
      if (!params) {
        this.superQueryParams = ''
        this.superQueryFlag = false
      } else {
        this.superQueryFlag = true
        this.superQueryParams = JSON.stringify(params)
        this.superQueryMatchType = matchType
      }
      this.loadData(1)
    },
    getQueryParams() {
      //获取查询条件
      let sqp = {}
      if (this.superQueryParams) {
        sqp['superQueryParams'] = encodeURI(this.superQueryParams)
        sqp['superQueryMatchType'] = this.superQueryMatchType
      }
      var param = Object.assign(sqp, this.queryParam, this.isorter, this.filters, this.searchOn)
      param.field = this.getQueryField()
      param.current = this.ipagination.current
      param.size = this.ipagination.pageSize
      if (this.permflag != undefined && this.permflag != null && this.permflag != '') {
        param.permflag = this.permflag
      }
      return filterObj(param)
    },
    getQueryField() {
      //TODO 字段权限控制
      var str = 'id,'
      this.columns.forEach(function (value) {
        str += ',' + value.dataIndex
      })
      return str
    },

    onSelectChange(selectedRowKeys, selectionRows) {
      this.selectedRowKeys = selectedRowKeys
      this.selectionRows = selectionRows
    },
    onClearSelected() {
      this.selectedRowKeys = []
      this.selectionRows = []
    },
    searchQuery() {
      this.loadData(1)
    },
    superQuery() {
      this.$refs.superQueryModal.show()
    },
    searchReset() {
      this.queryParam = {}
      if (this.tempUuid != undefined && this.tempUuid != null && this.tempUuid != '') {
        this.queryParam.tempUuid = this.tempUuid
      }
      if (this.permflag != undefined && this.permflag != null && this.permflag != '') {
        this.queryParam.permflag = this.permflag

      }
      this.loadData(1)
    },
    // 批量删除delete方法
    batchDel: function () {
      if (!this.url.deleteBatch) {
        this.$message.error('请设置url.deleteBatch属性!')
        return
      }
      // debugger
      if (this.selectedRowKeys.length <= 0) {
        this.$message.warning('请选择一条记录！')
      } else {
        var ids = this.selectedRowKeys+''
        var that = this
        this.$confirm({
          title: '确认删除',
          content: `已选中${this.selectedRowKeys.length}条,是否删除选中数据?`,
          onOk: function () {
            that.loading = true
            deleteAction(that.url.deleteBatch, { ids: ids }).then((res) => {
              if (res.success) {
                that.$message.success(res.message)
                that.loadData()
                that.onClearSelected()
              } else {
                that.$message.warning(res.message)
              }
            }).finally(() => {
              that.loading = false
            })
          }
        })
      }
    },
    stateChange(status) {
      if (!this.url.status) {
        this.$message.error('请设置url.status属性!')
        return
      }
      if (this.selectedRowKeys.length <= 0) {
        this.$message.warning('请选择一条记录！')

      } else {
        var ids = ''
        for (var a = 0; a < this.selectedRowKeys.length; a++) {
          ids += this.selectedRowKeys[a] + ','
        }
        var that = this
        this.$confirm({
          title: `确认${status == 1 ? '启用' : '停用'}`,
          content: `已选中${this.selectedRowKeys.length}条,是否${status == 1 ? '启用' : '停用'}选中数据?`,
          onOk: function () {
            that.loading = true
            getAction(that.url.status, { ids: ids, status }).then((res) => {
              if (res.success) {
                that.$message.success(res.message)
                that.loadData()
                that.onClearSelected()
              } else {
                that.$message.warning(res.message)
              }
            }).finally(() => {
              that.loading = false
            })
          }
        })
      }
    },
    // 行内切换状态
    async handleStatus(row, status, method = 'get') {
      let that = this
      if(!that.url.startOrStopUrl){
        this.$message.warning('请设置起停用接口')
        return
      }
      this.loading = true
      let params = { ids: row.id, id: row.id, status: Number(status) }
      let res = await httpAction(that.url.startOrStopUrl, params, method)
      if (res.success) {
        that.$message.success(res.message)
        that.onClearSelected()
      } else {
        that.$message.warning(res.message)
      }
      that.loadData()
    },
    passAll() {
      if (this.selectedRowKeys.length <= 0) {
        this.$message.warning('您还未选择要通过的数据')
        return
      }
      // 批量通过
      this.modalVisible = true
      this.$confirm({
        title: '确认通过',
        content:
          '您确认要通过所选的 ' +
          this.selectedRowKeys.length +
          ' 条数据? 注意：将默认分配给节点设定的所有可审批用户',
        loading: true,
        onOk: () => {
          let ids = ''
          this.selectionRows.forEach(function (e) {
            ids += e.id + ','
          })
          ids = ids.substring(0, ids.length - 1)
          getAction(this.url.passAll, { ids: ids, reviewState: 2 }).then(res => {
            if (res.success) {
              this.$message.success('操作成功')
              this.modalVisible = false
              this.loadData()
            }
          })
        }
      })
    },
    backAll() {
      if (this.selectedRowKeys.length <= 0) {
        this.$message.warning('您还未选择要驳回的数据')
        return
      }
      // 批量驳回
      this.modalVisible = true
      this.$confirm({
        title: '确认驳回',
        content:
          '您确认要驳回所选的 ' +
          this.selectedRowKeys.length +
          ' 条数据? 注意：所有流程将驳回至发起人',
        loading: true,
        onOk: () => {
          let ids = ''
          this.selectionRows.forEach(function (e) {
            ids += e.id + ','
          })
          ids = ids.substring(0, ids.length - 1)
          getAction(this.url.passAll, { ids: ids, reviewState: 3 }).then(res => {
            if (res.success) {
              this.$message.success('操作成功')
              this.modalVisible = false
              this.loadData()
            }
          })
        }
      })
    },
    // 加载树数据
    loadTreeDatas(arg) {
      // 加载查询接口
      let datasparams = {}
      if (arg) {
        datasparams = { ...this.searchOn, current: 1 }
      }
      if (!this.url.treeList) {
        this.$message.info('请配置树状接口地址"treeList"')
        return
      }
      postAction(this.url.treeList, datasparams).then(res => {
        console.log(res.result)
        this.treeData = [...res.result]
      })
    },
    onSearchs() {
      this.loadTreeDatas('1')
    },
    // 批量删除，post方法
    batchDelete: function () {
      if (!this.url.deleteBatch) {
        this.$message.error('请设置url.deleteBatch属性!')
        return
      }
      if (this.selectedRowKeys.length <= 0) {
        this.$message.warning('请选择一条记录！')

      } else {
        var ids = this.selectedRowKeys + ''
        var that = this
        this.$confirm({
          title: '确认删除',
          content: '是否删除选中数据?',
          onOk: function () {
            that.loading = true
            postAction(that.url.deleteBatch, { ids: ids }).then((res) => {
              if (res.success) {
                that.$message.success(res.message)
                that.loadData()
                that.onClearSelected()
              } else {
                that.$message.warning(res.message)
              }
            }).finally(() => {
              that.loading = false
            })
          }
        })
      }
    },
    // 批量删除，get方法
    getDelete: function () {
      if (!this.url.deleteBatch) {
        this.$message.error('请设置url.deleteBatch属性!')
        return
      }
      if (this.selectedRowKeys.length <= 0) {
        this.$message.warning('请选择一条记录！')

      } else {
        var ids = this.selectedRowKeys + ''
        var that = this
        this.$confirm({
          title: '确认删除',
          content: '是否删除选中数据?',
          onOk: function () {
            that.loading = true
            getAction(that.url.deleteBatch, { ids: ids }).then((res) => {
              if (res.success) {
                that.$message.success(res.message)
                that.loadData()
                that.onClearSelected()
              } else {
                that.$message.warning(res.message)
              }
            }).finally(() => {
              that.loading = false
            })
          }
        })
      }
    },
    // 根据id删除,get方法
    handleDelete: function (id) {
      if (!this.url.delete) {
        this.$message.error('请设置url.delete属性!')
        return
      }
      var that = this
      getAction(that.url.delete, { id: id }).then((res) => {
        if (res.success) {
          that.$message.success(res.message)
          that.loadData()
        } else {
          that.$message.warning(res.message)
        }
      })
    },
    // 根据id删除,delete方法
    handelDeleteAction: function (id) {
      if (!this.url.delete) {
        this.$message.error('请设置url.delete属性!')
        return
      }
      var that = this
      deleteAction(that.url.delete, { id: id }).then((res) => {
        if (res.success) {
          that.$message.success(res.message)
          that.loadData()
        } else {
          that.$message.warning(res.message)
        }
      })
    },

    handleEdit: async function (record) {
      if (this.url.detail) {
        const res = await getAction(this.url.detail, { id: record.id })
        if (res.success) {
          if (res.result) {
            record = res.result
          }
        } else {
          this.$message.error(res.message)
        }
      }
      this.$refs.modalForm.edit(record)
      this.$refs.modalForm.title = '编辑'
      this.$refs.modalForm.disableSubmit = false
    },
    handleAudit: async function (record) {
      if (this.url.detail) {
        const res = await getAction(this.url.detail, { id: record.id })
        if (res && res.result) {
          record = res.result
        }
      }
      this.$refs.modalForm.edit(record)
      this.$refs.modalForm.title = '审核'
      this.$refs.modalForm.disableSubmit = false
    },
    handleAdd: function () {
      this.$refs.modalForm.add()
      this.$refs.modalForm.title = '新增'
      this.$refs.modalForm.disableSubmit = false
      this.$refs.modalForm.model = {}
    },
    handleAddPhone: function () {
      this.$refs.modalFormPh.add()
      this.$refs.modalFormPh.title = '新增手机菜单'
      this.$refs.modalFormPh.disableSubmit = false
    },
    /**
     * 一对多功能 配置功能
     * @param record
     * @param type{role|position|org}
     * @param modal
     * @returns {boolean}
     */
    handleConfig(record, type, modal = 'ConfigModal') {
      this.$refs[modal].showModal(record)
      return false
    },
    handleEnable: function () {
      // this.$refs.modalForm.add();
      // this.$refs.modalForm.title = "新增";
      // this.$refs.modalForm.disableSubmit = false;
    },
    handleDisable: function () {
      // this.$refs.modalForm.add();
      // this.$refs.modalForm.title = "新增";
      // this.$refs.modalForm.disableSubmit = false;
    },
    handleTableChange(pagination, filters, sorter) {
      //分页、排序、筛选变化时触发
      //TODO 筛选
      if (Object.keys(sorter).length > 0) {
        this.isorter.column = sorter.field
        this.isorter.order = 'ascend' == sorter.order ? 'asc' : 'desc'
      }
      if (this.ipagination.current !== pagination.current) {
        this.selectionRows = []
        this.selectedRowKeys = []
      }
      this.ipagination = pagination
      this.loadData()
    },
    handleToggleSearch() {
      this.toggleSearchStatus = !this.toggleSearchStatus
    },
    // 给popup查询使用(查询区域不支持回填多个字段，限制只返回一个字段)
    getPopupField(fields) {
      return fields.split(',')[0]
    },
    async modalFormOk() {
      // 新增/修改 成功时，重载列表
      await this.loadData()
      this.$refs.modalForm.close()

    },
    async modalFormOkPh() {
      // 新增/修改 成功时，重载列表
      await this.loadData()
      this.$refs.modalFormPh.close()
    },

    handleDetail: async function (record, url, params, method = getAction, modalForm) {
      if (url || this.url.detail) {
        const res = await method(url || this.url.detail, params || { id: record.id })
        if (res && res.result) {
          record = res.result
        }
      }
      const modal = modalForm || this.$refs.modalForm
      modal.edit(record)
      modal.title = '详情'
      modal.disableSubmit = true

    },
    /* 导出 */
    handleExportXls2() {
      let paramsStr = encodeURI(JSON.stringify(this.getQueryParams()))
      let url = `${window._CONFIG['domianURL']}/${this.url.exportXlsUrl}?paramsStr=${paramsStr}`
      window.location.href = url
    },
    handleExportXls(fileName) {
      if (!fileName || typeof fileName != 'string') {
        fileName = '导出文件'
      }
      let param = { ...this.queryParam }
      if (this.selectedRowKeys && this.selectedRowKeys.length > 0) {
        param['selections'] = this.selectedRowKeys.join(',')
      }
      console.log('导出参数', param)
      downFile(this.url.exportXlsUrl, param).then((data) => {
        if (!data) {
          this.$message.warning('文件下载失败')
          return
        }
        if (typeof window.navigator.msSaveBlob !== 'undefined') {
          window.navigator.msSaveBlob(new Blob([data], { type: 'application/vnd.ms-excel' }), fileName + '.xls')
        } else {
          let url = window.URL.createObjectURL(new Blob([data], { type: 'application/vnd.ms-excel' }))
          let link = document.createElement('a')
          link.style.display = 'none'
          link.href = url
          link.setAttribute('download', fileName + '.xls')
          document.body.appendChild(link)
          link.click()
          document.body.removeChild(link) //下载完成移除元素
          window.URL.revokeObjectURL(url) //释放掉blob对象
        }
      })
    },
    downExportXls(key, obj = {}) {
      const downurl = window._CONFIG['domianJobURL'] + '/cnDownloadController/saveOrUpdate'
      if (!key || typeof key != 'string') {
        this.$message.warning('未配置接口标记！')
        return
      }
      let param = this.getQueryParams()
      let expParams = JSON.stringify(param)
      expParams = escape(expParams)
      postAction(downurl, { impKey: key, expParams: expParams, ...obj }).then((res) => {
        if (res.success) {
          this.$message.info(res.message + ',等待下载完成！')
        } else {
          this.$message.warn(res.message)
        }
      })
    },
    /* 导入 */
    handleImportExcel(info) {
      if (info.file.status !== 'uploading') {
        console.log(info.file, info.fileList)
      }
      if (info.file.status === 'done') {
        if (info.file.response.success) {
          // this.$message.success(`${info.file.name} 文件上传成功`);
          if (info.file.response.code === 201) {
            let { message, result: { msg, fileUrl, fileName } } = info.file.response
            let href = window._CONFIG['domianURL'] + fileUrl
            this.$warning({
              title: message,
              content: ('<div><span>{msg}</span><br/> <span>具体详情请 <a href={href} target="_blank" download={fileName}>点击下载</a> </span> </div>'
              )
            })
          } else {
            this.$message.success(info.file.response.message || `${info.file.name} 文件上传成功`)
          }
          this.loadData(1)
        } else {
          this.$message.error(`${info.file.name} ${info.file.response.message}.`)
        }
      } else if (info.file.status === 'error') {
        this.$message.error(`文件上传失败: ${info.file.msg} `)
      }
    },
    /* 图片预览 */
    getImgView(text) {
      if (text && text.indexOf(',') > 0) {
        text = text.substring(0, text.indexOf(','))
      }
      return getFileAccessHttpUrl(text)
    },
    /* 文件下载 */
    // update--autor:lvdandan-----date:20200630------for：修改下载文件方法名uploadFile改为downloadFile------
    downloadFile(text) {
      if (!text) {
        this.$message.warning('未知的文件')
        return
      }
      if (text.indexOf(',') > 0) {
        text = text.substring(0, text.indexOf(','))
      }
      let url = getFileAccessHttpUrl(text)
      window.open(url)
    },

    // 商品分类
    loadTreeData(params) {
      getProductCategory(params).then((res) => {
        if (res.success) {
          for (let i = 0; i < res.result.length; i++) {
            let temp = res.result[i]
            this.treeData.push(temp)
          }
        }

      })
    },
    // Vue防抖
    handlers(val, layOut) {
      let _this = this
      clearTimeout(this.timeout)
      this.timeout = setTimeout(() => {
        _this.handlerData(val)
      }, layOut)
    },
    // 数组删除按钮公用 params:source,数组源  arrkey 表格选中keys数组 rows选中项数组
    delectRow(source, arraykey, rows) {
      const dataSource = this[source]
      const selectedRowKeys = this[arraykey]
      const selectedRows = this[rows]
      for (let i = selectedRows.length - 1; i > -1; i--) {
        let num = dataSource.indexOf(selectedRows[i])
        this[source].splice(num, 1)
        this[arraykey].splice(num, 1)
        this[rows].splice(num, 1)
      }
    },
    consoleData(e1, e2, e3, e4) {
      let arr = [e1, e2, e3, e4]
      arr.forEach((item, index) => {
        if (item) {
          console.log(`这是第${index}个参数:${item}`)
        }
      })
    },
    // 小驼峰转换
    replaceReg(str) {
      var reg = /\b(\w)|\s(\w)/g
      let Key = str.split('_')
      if (Key.length > 0) {
        let fileds = Key[0]
        for (let i = 1; i < Key.length; i++) {
          Key[i] = Key[i].toLowerCase().replace(reg, function (m) {
            return m.toUpperCase()
          })
          fileds += Key[i]
        }
        return fileds
      } else {
        return str
      }
    },
    // 字典传值
    cataChange(e1, e2) {
      if (e2.dictCode == 'category_code') {
        this.form.setFieldsValue({
          categoryName: e2.dictDataDesc,
          categoryCode: e2.dictDataCode
        })
      } else if (e2.dictCode == 'brand_code') {
        this.form.setFieldsValue({
          brandName: e2.dictDataDesc,
          brandCode: e2.dictDataCode
        })
      } else if (e2.dictCode == 'term_channel') {
        this.form.setFieldsValue({
          channelName: e2.dictDataDesc,
          channelCode: e2.dictDataCode
        })
      } else if (e2.dictCode == 'product_type') {
        this.form.setFieldsValue({
          productTypeName: e2.dictDataDesc,
          productTypeCode: e2.dictDataCode
        })
      } else if (e2.dictCode == 'questionnaire_type') {
        this.form.setFieldsValue({
          problemTypeStr: e2.dictDataDesc,
          problemType: e2.dictDataCode
        })
      } else if (e2.dictCode == 'super_level') {
        this.form.setFieldsValue({
          problemTypeStr: e2.dictDataDesc,
          problemType: e2.dictDataCode
        })
      }
    }
  },
  filters: {
    isActiveStatus(status) {
      const statusMap = {
        0: '停用',
        1: '启用'
      }
      return statusMap[status]
    },
    isShelfStatus(status) {
      const statusMap = {
        1: '是',
        0: '否'
      }
      return statusMap[status]
    },
    filterCustType(status) {
      const statusMap = {
        '1': '省级',
        '2': '市级',
        '3': '区级',
        '4': '地区级'
      }
      return statusMap[status]
    },
    filterTerminalType(status) {
      const statusMap = {
        '1': '旗舰',
        '2': '形象',
        '3': '普通'
      }
      return statusMap[status]
    },

    filterOrderStatus(status) {
      return self.OrderStatus[status]
    }
  }

}
